﻿using System.Collections;
using Com.Enemy.EnemySystem.EnemyAI;
using Com.Enemy.EnemySystem.EnemyLifecycle;
using Pathfinding;
using Script.EnemySystem.EnemyState;
using UnityEngine;

namespace Script.Com.Enemy.EnemySystem.EnemyAI
{
    /// <summary>
    /// 卫兵个体AI
    /// </summary>
    public class ArcherStateState : EnemyStateBase
    {

        protected override void Start()
        {
            base.Start();
            
            animTime.AddStateTime(EnemyState.NormalAttack, 2);
            animTime.AddStateTime(EnemyState.Avoid, 8f/12);
            animTime.AddStateTime(EnemyState.Hurt, .5f);
            
            Body.Data.StateColdDown[(int)EnemyState.NormalAttack] = new BaseData(2);
            Body.Data.StateColdDown[(int)EnemyState.Avoid] = new BaseData(3);

            Body.Data.State = EnemyState.Idle;
        }

        protected override IEnumerator TakeDamageTask(int playerId, BaseData damage, float knockback)
        {
            GetIntoState(EnemyState.Hurt);
            Body.TakeDamage(playerId, damage, knockback);
            yield return new WaitForSeconds(animTime.GetStateTime(EnemyState.Hurt));
            ExitState();
        }
        
    }
}
